BIG O Notation


It is very important to analyze the algorithm, but before that we must know what is algorithm.

Algorithm is nothing but the procedure of solving problem.(Ex for algorithm)

If you are making a Cup of Tea what is the procedure?  Adding tea powder is imp without this how can you say the end product is Tea, sugar quantity varies person to person and you need to heat till the Tea ready the way you want. olla!!!!! Tea is ready. 

Similarly you need to use the functions, variables and conditionals statement to achieve your end desire.

There are some best procedures (Algorithms)to solve problems and they have names as well. Ex (Euclid algorithm to get HCF of a number)


How to compare algorithm:

To compare algorithm we use Big -O notation

Big - O notation represents the complexity of an algorithm. Here I mean Time complexity and space Complexity.

We can compare algorithm over time and memory allocation, but the speed is also depend on the hardware we used to run it.

 In simple words if the user input increases how much  time it took to run the code and how much space it require. If input increases linearly and time increases linearly as well it comes under worst case.



Runtimes of Big-O Functions

Here is a table of common Big-O functions:


Big-OName
1Constant
log(n)Logarithmic
nLinear
nlog(n)Log Linear
n^2Quadratic
n^3Cubic
2^nExponential


Sources: